<?php

namespace app\backend\validate;

use think\Validate;

class User extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名'	=>	['规则1','规则2'...]
     *
     * @var array
     */	
	protected $rule = [
	    'username' => ['require', 'max:15', 'unique:users'],
        'email' => ['email'],
        'password' => ['require', 'max:32']
    ];
    
    /**
     * 定义错误信息
     * 格式：'字段名.规则名'	=>	'错误信息'
     *
     * @var array
     */	
    protected $message = [
        'username.require' => '用户名必须',
        'username.max' => '用户名最多不超过15个字符',
        'username.unique' => '用户名已存在',
        'password.max' => '密码长度不超过32个字符',
        'password.require' => '密码必须',
        'email' => '邮箱格式不正确',
    ];
}
